package controller;

import Service.UserService;
import Service.impl.UserServiceimpl;
import pojo.Admin;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author LiangHaiBo
 * @version 1.0
 * @date 2021.8.30 上午 8:51
 */
@WebServlet("/regis")
public class Regis_Servlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");//解决post提交的中文乱码
        response.setContentType("text/html;charset= utf-8");//设置响应乱码

        //接收前台的数据
        String name = request.getParameter("name");
        String password = request.getParameter("password");

        //创建Service层接口对象
        UserService userService = new UserServiceimpl();
        userService.Regis(name,password);

        request.getRequestDispatcher("/login.jsp").forward(request, response);

    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doGet(request,response);

    }
}
